import java.util.Scanner;

public class demo1 {
    public static String fun(String[] strList,int n) {
        //检查是否为长度序
        boolean isSortByLength=true;
        boolean isSortByDic=true;
        for(int i=0;i<n-1;i++) {
            if(strList[i].compareTo(strList[i+1])>0) {
                isSortByDic=false;
            }
            if(strList[i].length()>strList[i+1].length()) {
                isSortByLength=false;
            }
        }
        if(isSortByDic&&isSortByLength) {
            return "both";
        } else if(isSortByDic&&!isSortByLength) {
            return "lexicographically";
        } else if(!isSortByDic&&isSortByLength) {
            return "lengths";
        } else {
            return "none";
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n=scanner.nextInt();
        String[] str=new String[n];
        for(int i=0;i<n;i++) {
            str[i]=scanner.next();
        }
        System.out.println(fun(str,n));
    }
}
